package test.login;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserList extends HttpServlet {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		doAttrivute(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		doAttrivute(req, resp);
	}

	protected void doAttrivute(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String id = req.getParameter("s_id");
		String user = req.getParameter("s_user");
		String adminFlg = req.getParameter("s_adminflg");

		UserSearch userSearch = new UserSearch();
		userSearch.setId(id);
		userSearch.setUser(user);
		userSearch.setAdminFlg(adminFlg);

		UserController uc = new UserController();
		List<User> userList = uc.getUserList(userSearch);

		req.setAttribute("userList", userList);

		req.getRequestDispatcher("/WEB-INF/userList.jsp").forward(req, resp);
	}

}
